/*
 * DefaultLayer.java
 *
 * Created on 28. Dezember 2006, 18:21
 *
 * Copyright (c) 2007 Daniel Gronau
 *
 * This file is part of KanjiTori.
 *
 * KanjiTori is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * KanjiTori is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
 *
 */

package kanjitori.map;

import kanjitori.map.Layer;
import kanjitori.map.tile.Tile;

/**
 *
 * @author Pirx
 */
class DefaultLayer implements Layer {
    
    private Tile[][] tiles;
    private float height;
    private Position size;
    private String name;
    
    /** Creates a new instance of DefaultLayer 
     * @param name 
     * @param size 
     * @param height 
     */
    public DefaultLayer(String name, Position size, float height) {
        this.size = size;
        this.height = height;
        this.name = name;
        tiles = new Tile[size.x()][size.y()];
    }

    public DefaultLayer(String name, Position size) {
        this(name, size, 0);
    }
    
    
    public Tile getTile(Position pos) {
        return tiles[pos.x()][pos.y()];
    }

    public void setTile(Position pos, Tile tile) {
        tiles[pos.x()][pos.y()] = tile;
    }

    public void setTile(Position pos, int width, int height, Tile tile) {
        for (int i = pos.x(); i < pos.x() + width; i++) {
            for (int j = pos.y(); j < pos.y() + height; j++) {
               tiles[i][j] = tile;
            }            
        }
    }
    
    public float getHeight() {
        return height;
    }
    
    public void setHeight(float height) {
        this.height = height;
    }

    public Position getSize() {
        return size;
    }

    public String getName() {
        return name;
    }
    
}
